package com.axjy.yycg.web;

import com.axjy.yycg.pojo.Menu;
import com.axjy.yycg.pojo.Sysuser;
import com.axjy.yycg.service.PermissionService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

@Controller
public class IndexHandler {
    @Resource
    private PermissionService permissionService;

    @GetMapping("/index")
    public String index(HttpSession session, Model model){
        Sysuser loginUser= (Sysuser) session.getAttribute("loginUser");
        Map<Menu,List<Menu>> nav=permissionService.createNav(loginUser.getId());
        model.addAttribute("nav",nav);
        return "index";
    }
}
